﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CopyDepartment.aspx.cs" Inherits="ZX.WebApp.EditWidows.OrganizationalManager.CopyDepartment" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="ZX.Web.UI.Controls" Namespace="ZX.Web.UI.Controls" TagPrefix="cc1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>移动部门</title>
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/menu/assets/skins/sam/menu.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link type="text/css" rel="stylesheet" href="../../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <link href="../../Scripts/yui_2.9.0/build/treeview/assets/treeview-core.css" rel="stylesheet"
        type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/fonts/fonts-min.css" />
    <link rel="stylesheet" type="text/css" href="../../scripts/yui_2.9.0/build/treeview/assets/skins/sam/treeview.css" />
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <!-- OPTIONAL: JSON Utility (for DataSource) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <!-- OPTIONAL: Connection Manager (enables XHR for DataSource) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <!-- OPTIONAL: Get Utility (enables dynamic script nodes for DataSource) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <!-- OPTIONAL: Drag Drop (enables resizeable or reorderable columns) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <!-- OPTIONAL: Calendar (enables calendar editors) -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/calendar/calendar-min.js"></script>
    <!-- Source files -->
    <script type="text/javascript" src="../../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../../scripts/yui_2.9.0/build/treeview/treeview-min.js"></script>
    <script src="../../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../../Scripts/Jquery.form.js" type="text/javascript"></script>
    
</head>
<body>
    <form id="form1" runat="server">
    
    <div>
        <cc1:TreeView ID="TreeView1" runat="server" Caption="DeptName" TableName="DatDepartment"    Key="DeptID" ParentKey="ParentID" path="DeptPath" AllowCheck="true" IsOutDepartment="0" IsVirtual="0"></cc1:TreeView>
    </div>
    </form>
     <form id="form2" action="../../Extend/AjaxData/DataProcessin.aspx">
       <textarea style="display: none" id="jsonDataContent" rows="2" cols="2" name="jsonDataContent"></textarea>
    </form>
</body>
<script type="text/javascript">
    var allowCheck = getPar1("allowCheck");
</script>
<script type="text/javascript">
    var tree2 = null;
    (function () {
        var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;

        Event.onDOMReady(function () {
            var layout = new YAHOO.widget.Layout({
                units: [
                //{ position: 'left', width: 160, body: 'treeDiv1', gutter: '1 2 1 1', header: '组织架构', collapse: true, scroll: true, zIndex: 1 },
                    {position: 'center', body: 'TreeView1', gutter: '1 2 1 1', header: '选取需要到移动的组织结构', scroll: true}]
            });
            layout.render();
        });
        var makeBranch = function (parent, label) {
        }
        //        var tree1 = new YAHOO.widget.TreeView("treeDiv1");
        //        makeBranch(tree1.getRoot());
        //        tree1.setNodesProperty('propagateHighlightUp', true);
        //        tree1.setNodesProperty('propagateHighlightDown', true);
        //        tree1.subscribe('clickEvent', tree1.onEventToggleHighlight);
        //        tree1.render();
        tree2 = new YAHOO.widget.TreeView("TreeView1");
        makeBranch(tree2.getRoot());
        tree2.setNodesProperty('propagateHighlightUp', true);
        tree2.setNodesProperty('propagateHighlightDown', true);
        tree2.subscribe('clickEvent', tree2.onEventToggleHighlight);
        tree2.subscribe('dblClickEvent', Native2);
        tree2.render();
        tree2._nodes[1].expand();

    })();
    var fkey,fcaption;
    function Native(caption, key) {
        fcaption =caption;
        fkey = key;
    }

    function Native2() {
        //debugger
        //fkey = key;
        var url = "../../Extend/AjaxData/DataProcessin.aspx?action=moveDept&sourceID=" + parent.fkey + "&parentID="+fkey;
        var formObject = document.getElementById('form2');
        YAHOO.util.Connect.setForm(formObject);
        YAHOO.util.Connect.asyncRequest('POST', url, {
            success: function (res) {
                var inventory;
                try {
                    inventory = JSON.parse(res.responseText);
                    if (inventory == 1) {
                        alert("保存成功!");
                        parent.YAHOO.example.container.dialog1.hide();
                    } else {
                        alert("保存失败!");
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("读取菜单数据错误：" + error.statusText);
            }
        }, null);       
    }




    function Save() {
        var hiLit = tree2.getNodesByProperty('highlightState', 1);
        if (YAHOO.lang.isNull(hiLit)) {
            alert("None selected");
        } else {
            var labels = [];
            for (var i = 0; i < hiLit.length; i++) {
                var node = tree2.getTreeDefinition();
                labels.push(hiLit[i].href.split("#@")[1]);
            }
            //alert(labels.join(","));
        }
        $("#jsonDataContent").val(labels);
        var formObject = document.getElementById('form2');
        YAHOO.util.Connect.setForm(formObject);
        var url = "../../Extend/AjaxData/DataProcessin.aspx?action=Move&entity=DatDepartment&parentId=" + parent.fkey + "";
        //alert(parent.pUserId);
        YAHOO.util.Connect.asyncRequest('POST', url, {
            success: function (res) {
                var inventory;
                try {
                    inventory = JSON.parse(res.responseText);
                    if (inventory == 1) {
                        alert("保存成功!");
                        parent.YAHOO.example.container.dialog1.hide();
                    } else {
                        alert("保存失败!");
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("读取菜单数据错误：" + error.statusText);
            }
        }, null);
    }
</script>
</html>
